import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from "@nestjs/common";

@Injectable()
export class RequiredPipe implements PipeTransform<any> {
    transform(value: any, metadata: ArgumentMetadata) {
        if (value == null || value === "") {
            throw new BadRequestException(`缺少必填参数 ${metadata.data || ""}`);
        }
        return value;
    }
}
